import picker from '@ohos.file.picker';

export function example() {

  let executor = (resolve, reject) => {
    try {

      let PhotoSelectOptions = new picker.PhotoSelectOptions();
      PhotoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE;
      PhotoSelectOptions.maxSelectNumber = 1;
      let photoPicker = new picker.PhotoViewPicker();
      photoPicker.select(PhotoSelectOptions, (err, PhotoSelectResult) => {
        // 状态获取失败
        if (err) {
          console.error('PhotoViewPicker.select failed with err: ' + err);
          reject(err)
          return;
        }
        console.info('PhotoViewPicker.select successfully, PhotoSelectResult uri: ' + JSON.stringify(PhotoSelectResult));
        // 状态获取成功
        resolve(PhotoSelectResult.photoUris[0]);
      });
    } catch (err) {
      console.error('PhotoViewPicker failed with err: ' + err);
    }

    // // 触发回调
    // resolve(people)
    // // 释放数据集的内存
    // resultSet.close();
    // })
  };

  let p: Promise<string> = new Promise(executor)
  return p

}